<template>
  <div class="content">
    <el-upload
      class="upload-demo"
      :action="$baseURL + 'admin/upload'"
      :on-remove="handleRemove"
      :before-remove="beforeRemove"
      multiple
      :limit="1"
      :file-list="fileList"
      accept=".pdf"
      :on-success="addFeudalSuccess"
    >
      <el-button size="small" type="primary">点击上传</el-button>
      <div slot="tip" class="el-upload__tip">
        只能上传jpg/png文件，且不超过500kb
      </div>
    </el-upload>
  </div>
</template>

<script>
export default {
  data() {
    return {
      fileList: [],
      upURL: $baseURL,
    };
  },

  methods: {
    handleRemove(file, fileList) {},

    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${
          files.length + fileList.length
        } 个文件`
      );
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },

    addFeudalSuccess(res, file, fileList) {
      return;
      if (res.code == 0) {
        this.$message({
          type: "success",
          message: "图片上传成功",
        });
        var imageUrls = baseURL + res.data;
        var img = {
          url: imageUrls,
          name: file.name,
        };
        // this.form.cover_image.push(imageUrls);
        this.form.cover_image.push(img);
        console.log(this.form.cover_image);
      } else {
        this.$message.error("上传失败");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
</style>